package com.zixuan.sina.controller;

import com.zixuan.sina.entity.Comment;
import com.zixuan.sina.service.CommentService;
import com.zixuan.sina.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/comment/")
public class CommentController {

    @Resource
    private CommentService commentService;
    //todo:根据文章获取相对应的评论
    @PostMapping("list")
    public Result listComment(@RequestBody Comment comment){
        return commentService.listComment(comment);
    }

    //添加评论
    @PostMapping("add")
    public Result add(@RequestBody Comment comment){

        return commentService.add(comment);
    }
    //删除评论
    @GetMapping("del/{commentId}")
    public Result delComment(@PathVariable("commentId") String commentId){

        return commentService.delComment(commentId);
    }

}
